home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / comm / uucp / AM114src.lha / notify.c < prev    next >
C/C++ Source or Header  |  1992-07-20  |  2KB  |  64 lines

  1. /*
  2.  *
  3.  *  AM --- AmigaMail
  4.  *  (C) 1991, 1992 by Christian Riede
  5.  *
  6.  *  AM is distributed in the hope that it will be useful, but WITHOUT ANY
  7.  *  WARRANTY.  No author or distributor accepts responsibility to anyone
  8.  *  for the consequences of using it or for whether it serves any
  9.  *  particular purpose or works at all, unless he says so in writing.
  10.  *  Refer to the GNU General Public License, Version 1, for full details.
  11.  *  
  12.  *  Everyone is granted permission to copy, modify and redistribute AM,
  13.  *  but only under the conditions described in the GNU General Public
  14.  *  License, Version 1.  A copy of this license is supposed to have been 
  15.  *  given to you along with AM so you can know your rights and responsi-
  16.  *  bilities.  It should be in a file named COPYING.  Among other things,
  17.  *  the copyright notice and this notice must be preserved on all copies.
  18.  *
  19.  *  
  20.  *
  21.  */
  22.  
  23. #include "am.h"
  24. #include "server.h"
  25.  
  26. void Notify(int User,int Event,int Number,struct Mail *Mail)
  27. {
  28.     struct NotifyPort *NotifyPort;
  29.     struct Mail *New;
  30.     struct AMMessage *Msg;
  31.  
  32.     for (NotifyPort = (struct NotifyPort *)NotifyPortList[User].lh_Head;
  33.         NotifyPort->np_Node.ln_Succ;
  34.         NotifyPort = (struct NotifyPort *)NotifyPort->np_Node.ln_Succ)
  35.         if (Msg = AllocAMMsg())        
  36.         {
  37.             if (Mail)
  38.             {
  39.                 /* give client a copy of the new item */
  40.                 New = AllocMem(sizeof(struct Mail),MEMF_CLEAR);
  41.                 if (New)
  42.                 {
  43.                     *New = *Mail;
  44.                     Msg->NewMail = New;
  45.                 }
  46.                 else
  47.                 {
  48.                     FreeMem(Msg,sizeof(struct AMMessage));
  49.                     break; /* don't send message when allocation has failed */
  50.                 }
  51.             }
  52.             
  53.             Msg->Number = Number;
  54.             Msg->Action = Event;
  55.  
  56.             /* no reply, client must free the message */
  57.             Msg->AMMsg.mn_ReplyPort = 0;
  58.  
  59.             PutMsg(NotifyPort->np_Port,(struct Message *)Msg);
  60.  
  61.         }
  62. }
  63.  
  64.